|
|
|
 | 5. Set the Name property of the BAS module to modAppCode. 6. Save this module using the name "AppCode.bas." 7. Create a Sub Main() procedure in the BAS file. Be sure to make it public. 8. Move any lines of code that explicitly reference those menus from the Employee Information form to the MDI form. 9. Add the following code to the Sub Main() procedure: | | Public Sub Main()
frmMain.Show
End Sub | | 10. Change the startup object to be the Sub Main() procedure you just added. 11. Select Project, EmpInfo Properties from the Visual Basic menu. 12. On the General tab, select "Sub Main" from the Startup Object combo box. |  | Now when you run this project, the MDI form will appear. You can then select the Employee menu item from the MDI menu and the Employee Information form will appear. Notice that the Employee Information form now has all the characteristics described for MDI child forms: You can only move it within the MDI parent form, you can minimize it and it will show up on the parent form, and so on. If you close the parent form, the Employee Information form will also be closed. This is probably the best featureyou only need to close one form, and all of the other forms close automatically. |
|
|
|
|
|
|
Child Menus in MDI Applications |
|
|
|
|
|
|
|
|
In the Employee application, you created menus on the MDI parent. Normally, most applications just have one menu. In an MDI application, you need to be very careful when creating menus on forms other than the MDI form. If a child form has a menu, the childs menu is displayed on the MDI form, not on the child form. When the child form has the focus, that childs menu replaces the MDI forms menu on the menu bar. If the child does not have a menu, the menu of the MDI form continues to be displayed. |
|
|
|
|
|
|
|
|
This behavior of overriding the menu on the MDI parent form only applies to MDI child forms. Standard forms that are not MDI child forms maintain separate menus, and these menus will not show up on the MDI parent. |
|
|
|
|
|